package rok3.zesp.projekt.models;

import rok3.zesp.projekt.models.abstracts.AbstractBuilding;
import rok3.zesp.projekt.models.abstracts.AbstractBullet;
import rok3.zesp.projekt.models.abstracts.AbstractExplosion;
import rok3.zesp.projekt.models.abstracts.AbstractHuman;
import rok3.zesp.projekt.models.abstracts.AbstractItem;
import rok3.zesp.projekt.models.interfaces.Collisable;
import rok3.zesp.projekt.models.objects.Human;

import com.badlogic.gdx.utils.Array;

public class PhysicCenter {
	Array<Collisable > arrayBullet;
	Array<Collisable > arrayHuman;
	Array<Collisable > arrayBuilding;
	Array<Collisable > arrayExplosion;
	Array<Collisable > arrayItem;
	
	public PhysicCenter () {
		arrayBullet = new Array<Collisable>(64);
		arrayHuman = new Array<Collisable> (16);
		arrayBuilding = new Array<Collisable> (16);
		arrayExplosion = new Array<Collisable> (32);
		arrayItem = new Array<Collisable> (16);
	}
	
	public void registerCollisbaleObject ( Collisable object ){
		if ( object instanceof AbstractHuman ) {
			arrayHuman.add(object);
		}
		if ( object instanceof AbstractBullet ) {
			arrayBullet.add(object);
		}
		if ( object instanceof AbstractExplosion ) {
			arrayExplosion.add(object);
		}
		if ( object instanceof AbstractItem ) {
			arrayItem.add(object);
		}
		if ( object instanceof AbstractBuilding ) {
			arrayBuilding.add(object);
		}
		
	}
	
	public void doPhysic() {
		Collisable first;
		for (int i = 0 ; i < arrayHuman.size; i ++ ) {
			first = arrayHuman.get(i);
			for (Collisable second : arrayBullet ) {
				if ( first.collideWith(second) ) {
					
				}
			}
			for (Collisable second : arrayItem ) {
				if ( first.collideWith(second) ) {
					
				}
			}
			for (Collisable second : arrayExplosion ) {
				if ( first.collideWith(second) ) {
					
				}
			}
			for (Collisable second : arrayBullet ) {
				if ( first.collideWith(second) ) {
					
				}
			}
		}
	}
}
